<template>
  <div style="line-height: 0;">
    <div style="margin-top: 15px; margin-bottom: 15px; line-height: 0; text-align: left;">
      <el-row>
        <label style="margin-left: 10px;">订单编号：</label>
        <el-input style="width: 200px;" prefix-icon="el-icon-search" v-model="params.orderCode" placeholder="请输入订单编号"></el-input>
        &nbsp;&nbsp;&nbsp;
        <label>树苗名称：</label>
        <el-input style="width: 200px;" prefix-icon="el-icon-search" v-model="params.treename" placeholder="请输入树苗名称"></el-input>
        &nbsp;&nbsp;&nbsp;
        <label>商家名称：</label>
        <el-input style="width: 200px;" prefix-icon="el-icon-search" v-model="params.username" placeholder="请输入商家名称"></el-input>
        &nbsp;&nbsp;&nbsp;
        <el-button type="warning" round style="margin-left: 10px;" @click="selectchangeorder">查询</el-button>
        &nbsp;&nbsp;&nbsp;
        <el-button type="warning" round style="margin-left: 10px;" @click="reset()">重置</el-button>
      </el-row>
    </div>
    <div>
      <el-table
          :data="tableData"
          border
          style="width: 100%">
        <el-table-column prop="order_id" v-if="false"></el-table-column>
        <el-table-column prop="ordercode" label="订单编号" width="180"></el-table-column>
        <el-table-column prop="treename" label="树苗名称" width="180"></el-table-column>
        <el-table-column prop="shopper" label="商家名称" width="180"></el-table-column>
        <el-table-column prop="number" label="树苗数量" width="180"></el-table-column>
        <el-table-column prop="summoney" label="订单总金额"></el-table-column>
        <el-table-column prop="orderTime" label="订单时间"></el-table-column>
        <el-table-column prop="orderstatusvalue" label="订单状态" width="180"></el-table-column>
        <el-table-column label="具体操作">
          <template slot-scope="scope">
            <el-button type="primary">取消订单</el-button>
            <el-button type="success">确认收货</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <div class="block" style="text-align: center;">
      <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="params.pageNum"
          :page-sizes="[5, 10, 15, 20]"
          :page-size="params.pageSize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total">
      </el-pagination>
    </div>

  </div>

</template>
<script>

import request from "@/utils/request";

export default {

  data() {
    return {
      params: {
        username:'',
        orderCode:'',
        treename:'',
        pageNum: 1,
        pageSize: 10
      },
      tableData: [],
      total: 0,
      formLabelWidth: '190px',
    }
  },
  //在页面加载的时候，做一些事情
  created() {
    this.loadchangeorder();
  },
  //定义一些页面上触发事件调用的方法
  methods:{
    loadchangeorder(){
      request.post("/order/loadchangeorder",this.params).then(res => {
        if (res.code === '0') {
          this.tableData = res.data.list;
          this.total = res.data.total;
          console.log(this.tableData)
        } else {
          this.$message.error(res.msg)
        }
      })
    },
    selectchangeorder(){
      request.post("/order/selectchangeorder",this.params).then(res => {
        if (res.code === '0') {
          this.tableData = res.data.list;
          this.total = res.data.total;
        } else {
          this.$message.error(res.msg)
        }
      })
    },
    reset(){
      this.params = {
        pageNum: 1,
        pageSize: 10,
        treename:'',
        username: '',
      }
      this.loadchangeorder();
    },
    handleSizeChange(pageSize){
      this.params.pageSize = pageSize;
      this.loadchangeorder();

    },
    handleCurrentChange(pageNum){
      this.params.pageNum = pageNum;
      this.loadchangeorder();

    },
  }
}
</script>